package com.aaa.controller;

import com.aaa.service.RoleService;
import com.aaa.vo.Result;
import com.aaa.vo.RoleVo;
import com.aaa.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @program: qy158-system
 * @description:
 * @author: 闫克起2
 * @create: 2022-10-11 10:32
 **/
@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public Result list(Integer userId){
        return roleService.findByUserId(userId);
    }

    @PostMapping("qr")
    public Result qr(Integer userId,Integer[] roleIds){

        return  roleService.qr(userId,roleIds);
    }

    @PostMapping("/all")
    public Result all(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize,
                      @RequestBody RoleVo roleVo){
        return roleService.findByCondition(currentPage,pageSize,roleVo);
    }
}
